Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom compiler crash/panic handler #731

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

JakubSchwenkbeck
Copy link
Contributor

@JakubSchwenkbeck JakubSchwenkbeck commented Dec 9, 2024

Motivation

Print and log a more verbose compiler crash/panic message with information about the specific user setup
Resolves #576.

Changes

Implemented the generateCrashReport function, which creates a more verbose output if the compiler crashes/panics.
This Report retrieves general and backend-specific information to make crashes more reproducable or traceable

It holds information about :

  • Effekt Version
  • Backend
  • OS
  • JVM
  • and a full stacktrace.

Additionally, the report is written to a .md-file in the .out/ directory

Examples:

Terminal Report

[info] === Effekt Compiler Crash Report ===

[Error] Internal compiler error: Error Text here bla bla

The compiler unexpectedly panicked. This is a compiler bug.
Please report it: https://github.com/effekt-lang/effekt/issues/new?labels=bug

Effekt Version: 0.13.0

Backend used: js

A detailed crash report has been written to:
/home/jakub/Effekt/repo/effekt/bin/./out

Operating System: Linux

JVM Version: 21.0.5

Full Stack Trace:
PlainTextError(Internal compiler error: Error Text here bla bla,None,Error)
        at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
        at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
        at effekt.Driver.compileSource(Driver.scala:54)
        at effekt.Driver.compileSource$(Driver.scala:21)
        at effekt.Server$.compileSource(Server.scala:261)
        at effekt.Server$.compileSource(Server.scala:261)
        at kiama.util.Compiler.compileFile(Compiler.scala:102)
        at kiama.util.Compiler.compileFile$(Compiler.scala:22)
        at effekt.Server$.compileFile(Server.scala:261)
        at effekt.Driver.run$$anonfun$1(Driver.scala:41)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at effekt.Driver.run(Driver.scala:42)
        at effekt.Driver.run$(Driver.scala:21)
        at effekt.Server$.run(Server.scala:261)
        at effekt.Server$.run(Server.scala:261)
        at kiama.util.Compiler.driver(Compiler.scala:86)
        at kiama.util.Compiler.driver$(Compiler.scala:22)
        at effekt.Server$.driver(Server.scala:261)
        at kiama.util.Compiler.main(Compiler.scala:50)
        at kiama.util.Compiler.main$(Compiler.scala:22)
        at effekt.Server$.main(Server.scala:261)
        at effekt.Server.main(Server.scala)


Arguments passed to the compiler:

compilercrash.effekt

Markdown Report

Effekt Compiler Crash Report

ERROR : Internal compiler error: Error Text here bla bla

The compiler unexpectedly panicked. This is a compiler bug.
Please report it: Submit an issue

Compiler Information

Effekt Version: 0.13.0

Backend: js

System Information

Operating System: Linux
Arch: amd64
Version: 5.15.167.4-microsoft-standard-WSL2

JVM Version: 21.0.5 (Ubuntu, OpenJDK Runtime Environment)

Full Stack Trace

PlainTextError(Internal compiler error: Error Text here bla bla,None,Error)
	at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
	at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
	at effekt.Driver.compileSource(Driver.scala:54)
	at effekt.Driver.compileSource$(Driver.scala:21)
	at effekt.Server$.compileSource(Server.scala:261)
	at effekt.Server$.compileSource(Server.scala:261)
	at kiama.util.Compiler.compileFile(Compiler.scala:102)
	at kiama.util.Compiler.compileFile$(Compiler.scala:22)
	at effekt.Server$.compileFile(Server.scala:261)
	at effekt.Driver.run$$anonfun$1(Driver.scala:41)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at effekt.Driver.run(Driver.scala:42)
	at effekt.Driver.run$(Driver.scala:21)
	at effekt.Server$.run(Server.scala:261)
	at effekt.Server$.run(Server.scala:261)
	at kiama.util.Compiler.driver(Compiler.scala:86)
	at kiama.util.Compiler.driver$(Compiler.scala:22)
	at effekt.Server$.driver(Server.scala:261)
	at kiama.util.Compiler.main(Compiler.scala:50)
	at kiama.util.Compiler.main$(Compiler.scala:22)
	at effekt.Server$.main(Server.scala:261)
	at effekt.Server.main(Server.scala)

Arguments Passed to the Compiler


compilercrash.effekt

JakubSchwenkbeck and others added 2 commits December 9, 2024 18:56
… report with Information about : OS, JVM, a full stacktrace . Additionally, the crash report is written into a log file
Copy link
Member

@marvinborner marvinborner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I think there are some design/layout choices that we could discuss (e.g. emitting markdown for copy/pasting to GitHub), but otherwise this looks like a good initial implementation.

We should also make sure that things like the System.getProperty calls work on all platforms (including Windows!)

JakubSchwenkbeck and others added 3 commits December 10, 2024 10:06
added correct Effekt Version
…piler/verbose-crash

# Conflicts:
#	effekt/jvm/src/main/scala/effekt/Driver.scala
@JakubSchwenkbeck JakubSchwenkbeck marked this pull request as ready for review December 16, 2024 13:34
@JakubSchwenkbeck
Copy link
Contributor Author

Hey:)
I completed my implementation and therefore switched from a draft to the PR.
I decided on logging the markdown version in a .md file and made some minor layout changes, an example is analog to the body of the main-comment, just with some md-specific highlighting

Copy link
Contributor

@jiribenes jiribenes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JakubSchwenkbeck, this seems like a great first draft.
Please take a look at my comments below to guide the next steps! :)

effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
@jiribenes
Copy link
Contributor

jiribenes commented Dec 17, 2024

Could you please post the current version of the generated report here, please? :)

@JakubSchwenkbeck
Copy link
Contributor Author

I'm flexible with the design, changing the layout / contet only needs minor String-manipulations, so feel free to knitpick:)

@JakubSchwenkbeck
Copy link
Contributor Author

JakubSchwenkbeck commented Jan 15, 2025

Note

context.report(msg) is effectfull! Without calling, the programm results in a NullPointerException regarding kiama- messages

Working:

case e @ CompilerPanic(msg) => 
      context.report(msg)
      generateCrashReport(e, context, config, msg)

NOT Working:

case e @ CompilerPanic(msg) =>  generateCrashReport(e, context, config, msg)

dvdvgt pushed a commit that referenced this pull request Jan 15, 2025
Resolves the `Effect Compiler Crash: null` part of #760.
The actual problem there was that `e.getMessage` can return `null` and
it does for... _StackOverflowException_ 🥳.
Looking at the docs, it's recommended to use `e.toString`.

While I was at it, I modified stack trace printing, now we do it
properly by using `.printStackTrace`.

This is very related to #731, I just want to get this out quickly to
unblock other problems.
@JakubSchwenkbeck
Copy link
Contributor Author

JakubSchwenkbeck commented Jan 16, 2025

Hey @jiribenes , @marvinborner :) I would be happy to receive some input (/approval) regarding the design of both the terminal and the markdown report:) Examples for both are found in the opening message of this PR!

dvdvgt pushed a commit that referenced this pull request Jan 17, 2025
Resolves the `Effect Compiler Crash: null` part of #760.
The actual problem there was that `e.getMessage` can return `null` and
it does for... _StackOverflowException_ 🥳.
Looking at the docs, it's recommended to use `e.toString`.

While I was at it, I modified stack trace printing, now we do it
properly by using `.printStackTrace`.

This is very related to #731, I just want to get this out quickly to
unblock other problems.
EveEme pushed a commit to EveEme/effekt that referenced this pull request Jan 20, 2025
Resolves the `Effect Compiler Crash: null` part of effekt-lang#760.
The actual problem there was that `e.getMessage` can return `null` and
it does for... _StackOverflowException_ 🥳.
Looking at the docs, it's recommended to use `e.toString`.

While I was at it, I modified stack trace printing, now we do it
properly by using `.printStackTrace`.

This is very related to effekt-lang#731, I just want to get this out quickly to
unblock other problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom compiler crash/panic handler
3 participants